package likou;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/07/12 13:29
 */
public class _50 {
    public static void main(String[] args) {
        System.out.println(myPow(2.00000,
                -2147483648));
    }
    public static double myPow(double x, int n) {
        if(x==0){
            return 0;
        }
        if(n==0||x==1.0){
            return 1;
        }
        if(n<0){
            x = 1.0/x;
        }
        return forkjoin(x,n);
    }
    public static double forkjoin(double x,int n){
        if(n==1||n==-1){
            return x;
        }
        if(n%2==1||n%2==-1){
            return x*forkjoin(x*x,n/2);
        }
        return forkjoin(x*x,n/2);
    }
}
